/* File Name : Event.java */

package com.chenwenxuan.sync.event;

/**
 * This class encapsulates all the parameters that define the functional requirements of an
 * individual event.
 * 
 * @author Jose Heitor
 * @version 1.0
 */
public class Event
{
  private final String name;
  private final int threading;
  private final boolean queueing;
  
  /**
   * Optional constructor. Creates an instance of this class and initializes the properties
   * that define the operational characteristics of this event.
   * 
   * @param name The name of this event.
   */
  public Event(String name) {this(name, 0, false);}
  
  /**
   * Optional constructor. Creates an instance of this class and initializes the properties
   * that define the operational characteristics of this event.
   * 
   * @param name The name of this event.
   * @param threadingPriority Defines whether this event is dispatched synchronously (Single-Threaded
   * Model) or asynchronously (Multi-Threaded Model). Accepted values:
   * <p>
   * <li><b>0</b> - Dispatched synchronously (immediately in the same thread as the source).
   * <li><b>1</b> - Dispatched asynchronously (seperate thread from the source) at 100 millisecond intervals.
   * <li><b>2</b> - Dispatched asynchronously (seperate thread from the source) at 200 millisecond intervals.
   * <li><b>3</b> - Dispatched asynchronously (seperate thread from the source) at 300 millisecond intervals.
   * <li><b>4</b> - Dispatched asynchronously (seperate thread from the source) at 400 millisecond intervals.
   * <li><b>5</b> - Dispatched asynchronously (seperate thread from the source) at 500 millisecond intervals.
   * <p>
   * <i><b>NOTE:</b> No 'queue' (buffer) is used by default (i.e. if events are generated at shorter intervals than
   * the chosen dispatch priority, some events WILL be lost).</i>
   */
  public Event(String name, int threadingPriority)
  {
    this(name, threadingPriority, false);
  }
  
  /**
   * Optional constructor. Creates an instance of this class and initializes the properties
   * that define the operational characteristics of this event.
   * 
   * @param name The name of this event.
   * @param threadingPriority Defines whether this event is dispatched synchronously (Single-Threaded
   * Model) or asynchronously (Multi-Threaded Model). Accepted values:
   * <p>
   * <li><b>0</b> - Dispatched synchronously (immediately in the same thread as the source).
   * <li><b>1</b> - Dispatched asynchronously (seperate thread from the source) at 100 millisecond intervals.
   * <li><b>2</b> - Dispatched asynchronously (seperate thread from the source) at 200 millisecond intervals.
   * <li><b>3</b> - Dispatched asynchronously (seperate thread from the source) at 300 millisecond intervals.
   * <li><b>4</b> - Dispatched asynchronously (seperate thread from the source) at 400 millisecond intervals.
   * <li><b>5</b> - Dispatched asynchronously (seperate thread from the source) at 500 millisecond intervals.
   * <p>
   * @param queue If set to <code>true</code> a FIFO 'queue' will be used with a maximum capacity of 2,147,483,647.
   * Once the maximum number of events have been 'queued' (buffered), new events will simply be discarded.
   * <p>
   * <i><b>NOTE:</b> If set to <code>false</code>, no 'queue' is iused by defaul (i.e. if events are
   * generated at shorter intervals than the chosen dispatch priority, some events WILL be lost).</i>
   */
  public Event(String name, int threadingPriority, boolean queue)
  {
    this.name = name;
    threading = threadingPriority;
    queueing = queue;
  }
  
  public String getName() {return name;}
  
  public int getThreadPriority() {return threading;}
  
  public boolean getQueue() {return queueing;}
}